NB IoT 6 Click
NB IoT 6 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Apr 2025.
- Type : UART type
Software Support
Example Description
Application example shows device capability of connecting to the network and sending SMS or TCP/UDP messages using standard "AT" commands.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.NBIoT6
Example Key Functions
- nbiot6_cfg_setup This function initializes Click configuration structure to initial values.
void nbiot6_cfg_setup(nbiot6_cfg_t *cfg)
NB IoT 6 configuration object setup function.
NB IoT 6 Click configuration object.
Definition nbiot6.h:195
- nbiot6_init This function initializes all necessary pins and peripherals used for this Click board.
err_t nbiot6_init(nbiot6_t *ctx, nbiot6_cfg_t *cfg)
NB IoT 6 initialization function.
NB IoT 6 Click context object.
Definition nbiot6.h:171
- nbiot6_set_power_state This function sets a desired power state by toggling PWR, RST, and WUP pins with a specific time frame.
void nbiot6_set_power_state(nbiot6_t *ctx, uint8_t state)
NB IoT 6 set power state function.
- nbiot6_cmd_run This function sends a specified command to the Click module.
void nbiot6_cmd_run(nbiot6_t *ctx, uint8_t *cmd)
NB IoT 6 cmd run function.
- nbiot6_cmd_set This function sets a value to a specified command of the Click module.
void nbiot6_cmd_set(nbiot6_t *ctx, uint8_t *cmd, uint8_t *value)
NB IoT 6 cmd set function.
- nbiot6_send_sms_text This function sends text message to a phone number.
void nbiot6_send_sms_text(nbiot6_t *ctx, uint8_t *phone_number, uint8_t *sms_text)
NB IoT 6 send SMS in text mode function.
Application Init
Initializes the driver and logger.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( UART_ERROR ==
nbiot6_init( &nbiot6, &nbiot6_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
log_printf( &logger, ">>> APP STATE - POWER UP <<<\r\n\n" );
}
#define NBIOT6_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition nbiot6.h:155
void application_init(void)
Definition main.c:212
@ NBIOT6_POWER_UP
Definition main.c:92
Application Task
Application task is split in few stages:
- NBIOT6_POWER_UP:
Powers up the device and reads system information.
- NBIOT6_CONFIG_CONNECTION:
Sets configuration to device to be able to connect to the network.
- NBIOT6_CHECK_CONNECTION:
Waits for the network registration indicated via CEREG command and then checks the signal quality report.
- NBIOT6_CONFIG_EXAMPLE:
Configures device for the selected example.
- NBIOT6_EXAMPLE:
Depending on the selected demo example, it sends an SMS message (in PDU or TXT mode) or TCP/UDP message. By default, the TCP/UDP example is selected.
{
switch ( app_state )
{
{
if (
NBIOT6_OK == nbiot6_power_up( &nbiot6 ) )
{
log_printf( &logger, ">>> APP STATE - CONFIG CONNECTION <<<\r\n\n" );
}
break;
}
{
if (
NBIOT6_OK == nbiot6_config_connection( &nbiot6 ) )
{
log_printf( &logger, ">>> APP STATE - CHECK CONNECTION <<<\r\n\n" );
}
break;
}
{
if (
NBIOT6_OK == nbiot6_check_connection( &nbiot6 ) )
{
log_printf( &logger, ">>> APP STATE - CONFIG EXAMPLE <<<\r\n\n" );
}
break;
}
{
if (
NBIOT6_OK == nbiot6_config_example( &nbiot6 ) )
{
log_printf( &logger, ">>> APP STATE - EXAMPLE <<<\r\n\n" );
}
break;
}
{
nbiot6_example( &nbiot6 );
break;
}
default:
{
log_error( &logger, " APP STATE." );
break;
}
}
}
@ NBIOT6_CONFIG_CONNECTION
Definition main.c:93
@ NBIOT6_CHECK_CONNECTION
Definition main.c:94
@ NBIOT6_EXAMPLE
Definition main.c:96
@ NBIOT6_CONFIG_EXAMPLE
Definition main.c:95
void application_task(void)
Definition main.c:245
@ NBIOT6_OK
Definition nbiot6.h:221
Note
In order for the examples to work, user needs to set the APN and SMSC (SMS PDU mode only) of entered SIM card as well as the phone number (SMS mode only) to which he wants to send an SMS. Enter valid values for the following macros: SIM_APN, SIM_SMSC and PHONE_NUMBER.
Example:
- SIM_APN "internet"
- SIM_SMSC "+381610401"
- PHONE_NUMBER "+381659999999"
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.